import { DisposeView } from "../../../mvc/core/DisposeView";
import { GTextFiled } from "../../../../com/mui/controls/GTextFiled";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { SCrossSWObserveListInfo } from "../../../../Message/Public/SCrossSWObserveListInfo";
import { HTMLUtil } from "../../../../com/gengine/utils/HTMLUtil";
import { EntityUtil } from "../../scene/layer/utils/EntityUtil";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { ObjCreate } from "../common/ObjCreate";
import { ImagesConst } from "../../resource/ImagesConst";
import { GButton } from "../../../../com/mui/controls/GButton";
import { Vector } from "../../../../__AS3__/vec/Vector";
//class AttachedSoulBattlefielListInfoView
    
    export  class AttachedSoulBattlefielListInfoView extends DisposeView
    {
        constructor()
        {
            super();
            this._list = new Vector.<GTextFiled>();
            return;
        }

        /* internal  */onTxtLinkHandler(arg1: Object /* flash.events.TextEvent */): void
        {
            var loc1=String(arg1.target.name).split("_");
            var loc2=loc1[1];
            Dispatcher.dispatchEvent(new DataEvent(EventName.PlayerInfo_view, SCrossSWObserveListInfo(this._data[loc2]).entityId));
            return;
        }

        /* internal  */closeBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            this.hide();
            return;
        }

        public set data(arg1: Array<any>)
        {
            var loc1=null;
            var loc2=null;
            var loc4=0;
            this._data = arg1;
            var loc3=this._data.length;
            while (loc4 < loc3) 
            {
                loc2 = this._data[loc4] as SCrossSWObserveListInfo;
                loc1 = this._list[loc4] as GTextFiled;
                loc1.htmlText = HTMLUtil.addLink(EntityUtil.getProxyName(loc2.entityId) + loc2.name, GlobalStyle.color1);
                this.addChild(loc1);
                ++loc4;
            }
            this.addChild(this._viewCloseBtn);
            return;
        }

        protected /* override */ createDisposedChildrenImpl(): void
        {
            var loc2=null;
            super.createDisposedChildrenImpl();
            pushUIToDisposeVec(ObjCreate.createBg(0, 0, 160, 160, this, ImagesConst.ToolTipBg));
            var loc1=0;
            while (loc1 < 5) 
            {
                loc2 = ObjCreate.createGTextField("", 0, 5 + 30 * loc1, 160, 20, null, GlobalStyle.setTextFormatAlign(GlobalStyle._textFormat1, flash.text.TextFormatAlign.CENTER));
                loc2.name = "txt_" + loc1;
                loc2.configEventListener(flash.events.TextEvent.LINK, this.onTxtLinkHandler);
                this._list.push(loc2);
                pushUIToDisposeVec(loc2);
                ++loc1;
            }
            this._viewCloseBtn = ObjCreate.createGButton("", 140, 2, 19, 19, this, "CloseButton");
            this._viewCloseBtn.configEventListener(flash.events.MouseEvent.CLICK, this.closeBtnClickHandler);
            return;
        }

        protected /* override */ disposeImpl(arg1: Boolean=true): void
        {
            super.disposeImpl(arg1);
            this._viewCloseBtn.dispose(arg1);
            this._list = new Vector.<GTextFiled>();
            return;
        }

        /* internal */ /* var */_viewCloseBtn: GButton;

        /* internal */ /* var */_list: Vector.<GTextFiled>;

        /* internal */ /* var */_data: Array<any>;
    }
